package com.sm.healthy.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.sm.healthy.R
import com.sm.healthy.data.bean.BloodPressureEntity
import com.sm.healthy.databinding.ItemHistoryDataBinding

/**
 * 历史数据列表
 */
class HistoryBloodPressureListAdapter(
    layoutId: Int = R.layout.item_history_data,
    list: MutableList<BloodPressureEntity> = arrayListOf()
) : BaseQuickAdapter<BloodPressureEntity, BaseDataBindingHolder<ItemHistoryDataBinding>>(
    layoutId,
    list
) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemHistoryDataBinding>,
        item: BloodPressureEntity
    ) {
        holder.dataBinding?.bloodPress = item

        when {
            item.levelSys <= 90 -> {
                holder.dataBinding?.textView14?.text = "↓"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.levelSys in 91..139 -> {
                holder.dataBinding?.textView14?.text = ""

            }
            item.levelSys > 140 -> {
                holder.dataBinding?.textView14?.text = "↑"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#de253b"))
            }
        }
        when {
            item.levelDia <= 60 -> {
                holder.dataBinding?.textView13?.text = "↓"
                holder.dataBinding?.textView13?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.levelDia in 61..89 -> {
                holder.dataBinding?.textView13?.text = ""
            }
            item.levelDia > 90 -> {
                holder.dataBinding?.textView13?.text = "↑"
                holder.dataBinding?.textView13?.setTextColor(Color.parseColor("#de253b"))
            }
        }
        when {
            item.levelPul <= 60 -> {
                holder.dataBinding?.textView9?.text = "↓"
                holder.dataBinding?.textView9?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.levelPul in 61..99 -> {
                holder.dataBinding?.textView9?.text = ""
            }
            item.levelPul > 100 -> {
                holder.dataBinding?.textView9?.text = "↑"
                holder.dataBinding?.textView9?.setTextColor(Color.parseColor("#de253b"))
            }
        }
    }
}